Skip to content

Refactor install-age calculation into AppInstall.getInstallAge()#9004

Open
lmac012 wants to merge 1 commit into
developfrom
fix/lukasz/get-install-age-bucket-refactor
Open

Refactor install-age calculation into AppInstall.getInstallAge()#9004
lmac012 wants to merge 1 commit into
developfrom
fix/lukasz/get-install-age-bucket-refactor

Conversation

@lmac012

@lmac012 lmac012 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Task/Issue URL: https://app.asana.com/1/137249556945/project/488551667048375/task/1215957241503520?focus=true
Tech Design URL (if applicable):

Description

Extracts the "time since install" calculation out of DuckChatJSHelper behind a new suspend fun AppInstall.getInstallAge(): Duration? (kotlin.time). getInstallAgeBucket() is now a thin mapping from the returned Duration to the existing buckets, and the withContext(io) + clock + Instant/ChronoUnit plumbing moves into AppInstallRepository.

getInstallationTimestamp() is unchanged, so the attributed-metrics consumers are untouched. The Duck.ai install-age pixel semantics are unchanged (null when the timestamp is not recorded or is in the future).

Note: this adds a method to the :browser-api AppInstall public API; a separate API proposal accompanies it.

Steps to test this PR

QA-optional

No UI changes

Extract the elapsed-time-since-install logic out of DuckChatJSHelper behind a new suspend AppInstall.getInstallAge(): Duration?. Pixel bucketing semantics are unchanged.

Asana: https://app.asana.com/1/137249556945/project/488551667048375/task/1215957241503520?focus=true

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

lmac012 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@lmac012 lmac012 marked this pull request as ready for review June 26, 2026 12:45
@lmac012 lmac012 requested a review from malmstein June 26, 2026 13:44

@malmstein malmstein left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed statically — pure behaviour-preserving refactor with green CI. Nice cleanup moving the install-age math into AppInstall.getInstallAge(): Duration?, which encapsulates the io() dispatch and the null edge cases behind the api. Bucket boundaries preserved exactly, new AppInstallRepositoryTest covers the branches, and dispatcherProvider is still used elsewhere so no dead dep. One non-blocking nit inline.

@Test
fun whenInstallTimestampNotRecordedThenInstallAgeIsOmitted() = runTest {
whenever(mockAppInstall.getInstallationTimestamp()).thenReturn(0L)
fun whenInstallAgeIsNullBecauseNotRecordedThenInstallAgeIsOmitted() = runTest {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: now that the future/not-recorded distinction lives in getInstallAge(), this test and whenInstallAgeIsNullBecauseInFutureThenInstallAgeIsOmitted above have identical bodies (getInstallAge() → null → omitted). the two scenarios are already covered properly in AppInstallRepositoryTest, so we could collapse these into one "null age → param omitted" test here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants